#!/usr/bin/env python
# -*- coding: utf-8 -*-

# ============================================================================
#    File: task_add.py
#
#    Desc: NULL
#
# Version: 1.0
#    Date: 2014-04-15 15:06:46
#  Author: huabo (daijun), caodaijun@baidu.com
# Company: baidu.com
#
#                          --- Copyleft (c), 2013 ---
#                              All Rights Reserved.
# ============================================================================


import json
import urllib
import httplib


def main():
    host = 'cq01-test-nlp1.cq01.baidu.com:8962'

    httpParams = urllib.urlencode({
         "creator"       : "caodaijun",
         "stream_id"     : "1",
         "task_name"     : "baseData",
         "desc"          : "base data description",
         "config"        : "base data config",
         "tool_name"     : "test",
         "tool_version"  : "1",
         "expect_start"  : "9:30",
         "expect_finish" : "18:30",
    })
    httpHeaders = {"Content-type":"application/x-www-form-urlencoded", "Accept":"text/plain"}
    conn = httplib.HTTPConnection(host)
    conn.request("POST", "/task/add", httpParams, httpHeaders)
    response = conn.getresponse()
    print response.read()


if __name__ == "__main__":
    main()
